package com.tencent.backstage.controller;

import com.github.pagehelper.PageInfo;
import com.tencent.common.pojo.Result;
import com.tencent.common.pojo.StatusCode;
import com.tencent.backstage.pojo.ChapterAndVideo;
import com.tencent.backstage.pojo.Course;
import com.tencent.backstage.pojo.CourseType;
import com.tencent.backstage.service.CourseService;
import com.tencent.backstage.vo.CourseVo;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("course")
public class CourseController {

    @Resource
    private CourseService cs;

    @RequestMapping("getCourseType")
    public Result getCourseType(){
        List<CourseType> list = cs.getCourseType();
        return new Result(StatusCode.OK,"课程类型查询成功",true,list);
    }

    @RequestMapping("getCourseList")
    public Result getCourseList(@RequestBody CourseVo courseVo){
        PageInfo<Course> list = cs.getCourseList(courseVo);
        return new Result(StatusCode.OK,"课程列表查询成功",true,list);
    }

    @RequestMapping("getCourseChapterAndVideoList")
    public Result getCourseChapterAndVideoList(@RequestBody Course course){
        List<ChapterAndVideo> list = cs.getCourseChapterAndVideoList(course);
        return new Result(StatusCode.OK,"章节列表查询成功",true,list);
    }
}
